package implementor;

import daoInterface.TransactionCategoryDao;
import dbhandeling.Crude;
import dto.TransactionCategory;

public class TransactionCategoryDaoImplementor extends Crude implements TransactionCategoryDao
{
String className=new TransactionCategory().getClass().getName();
@Override
public void add(TransactionCategory transactioncategory) throws Exception
{
insert(transactioncategory);
}
/***********************************************************/
@Override
public void update(TransactionCategory transactioncategory) throws Exception
{
super.update(className,"categoryName",transactioncategory.getcategoryName()+"","autoTransCatId",transactioncategory.getautoTransCatId()+"");
super.update(className,"type",transactioncategory.gettype()+"","autoTransCatId",transactioncategory.getautoTransCatId()+"");
super.update(className,"status",transactioncategory.getstatus()+"","autoTransCatId",transactioncategory.getautoTransCatId()+"");
}
/***********************************************************/
@Override
public void delete(TransactionCategory transactioncategory) throws Exception
{
super.delete(className,"autoTransCatId",transactioncategory.getautoTransCatId()+"");
}
/***********************************************************/
@Override
public TransactionCategory retrieve(String conditionField,String conditionValue) throws Exception
{
TransactionCategory transactioncategory=(TransactionCategory) super.retreive(className,conditionField,conditionValue);
return transactioncategory;
}
/***********************************************************/
@Override
public TransactionCategory[] retrieveArray(String conditionField,String conditionValue) throws Exception
{
TransactionCategory[] transactioncategory;
Object[] obj=super.retreiveArrayOnCondition(className,conditionField, conditionValue);
transactioncategory=new TransactionCategory[obj.length];
for(int i=0;i<transactioncategory.length;i++)
{
transactioncategory[i]=(TransactionCategory) obj[i];
}
return transactioncategory;
}
/***********************************************************/
@Override
public TransactionCategory[] retrieveAll() throws Exception
{
TransactionCategory[] transactioncategory;
Object[] obj=super.retreiveAll(className);
transactioncategory=new TransactionCategory[obj.length];
for(int i=0;i<transactioncategory.length;i++)
{
transactioncategory[i]=(TransactionCategory) obj[i];
}
return transactioncategory;
}
/***********************************************************/
public int getAutoGenratedKey()
{
	 int key=super.getAutoGenratedKey(className,"autoTransCatId") ;
	 return key;
}
}
